#!/bin/sh
cd ${0%/*} || exit 1    # Run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

runApplication blockMesh
runApplication createNonConformalCouples nonCoupleStationary nonCoupleRotating

runApplication setFields

runApplication decomposePar -cellProc
runParallel foamRun
runApplication reconstructPar -cellProc

# Link cellProc files at unchanged times back to cellProc files at previous
# changed times. This allows them to be visualised continuously.
tPrev=0
foamListTimes | while read -r t
do
    if [ -f "$t"/cellProc ]
    then
        tPrev="$t"
    else
        ln -s ../"$tPrev"/cellProc "$t"/cellProc
    fi
done

#------------------------------------------------------------------------------
